import {menulist} from "@/request/api.js"

export default {
    //定义数据
    state:{
        menuList:[]
    },
    //获取数据
    getters:{
        get_menuList(state){
            return state.menuList;
        }
    },
    //修改数据 -- 修改数据的唯一方式
    mutations:{
        //state:仓库原始数据，payload调用函数时传递的参数
        mutation_menuList(state,payload){
            state.menuList = payload
        }
    },
    //异步操作，发请求
    actions:{
       async action_menuList({commit},payload){
            let res = await menulist();
            if(res.code == 200){
                //修改menuList的数据 --- mutations
                commit("mutation_menuList",res.list)
            }
        }
    },
    //开启命名空间
    namespaced:true
}